package edu.zut.cs.software.perfect.student.domain;

import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;

import edu.zut.cs.software.perfect.base.domain.BaseTreeEntity;

/**
 * @ClassName Classes
 * @Description TODO
 * @Author jihao
 * @Date 2020年5月29日 下午3:25:30
 * @Version 1.0
 */

@Entity
@Table(name = "T_CLASSES")
@NamedQueries({ @NamedQuery(name = "Classes.getRoot", query = "select m from Classes m where m.parent is null") })
public class Classes extends BaseTreeEntity<Classes,Long>{

	/**
	 * 
	 */
	private static final long serialVersionUID = 3819361231562502155L;
	
	@Column(name = "CLASSID")
	String ClassID;
	/**
	 * classid for ProcessRegistrar
	 */
	
	@Column(name = "CLASSNAME")
	String ClassName;
	/**
	 * className for class
	 */
	
	@Column(name = "stuNumber")
	String stuNumber;
	/**
	 * student_number for class
	 */
	
	@Column(name = "Leader")
	String Leader;
	/**
	 * teacher for class
	 */
	
	public String getLeader() {
		return Leader;
	}

	public void setLeader(String leader) {
		Leader = leader;
	}

	public String getStuNumber() {
		return stuNumber;
	}

	public void setStuNumber(String stuNumber) {
		this.stuNumber = stuNumber;
	}

	/**
	 * One Class relate to many students.
	 */
	@OneToMany(mappedBy="Classes",cascade=CascadeType.REMOVE,fetch=FetchType.EAGER)
	List<Student> students;

	public String getClassName() {
		return ClassName;
	}

	public void setClassName(String className) {
		ClassName = className;
	}

	public String getClassID() {
		return ClassID;
	}

	public void setClassID(String classID) {
		ClassID = classID;
	}

	public List<Student> getStudents() {
		return students;
	}

	public void setStudents(List<Student> students) {
		this.students = students;
	}

	public static long getSerialversionuid() {
		return serialVersionUID;
	}
	
	@Override
	public boolean equals(Object obj) {
		return EqualsBuilder.reflectionEquals(this, obj);
	}

	@Override
	public int hashCode() {
		return HashCodeBuilder.reflectionHashCode(this);
	}

	@Override
	public String toString() {
		return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
	}
	
}
